<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<html>
    <head>
        <title>Edit User</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="stylesheet.css">
        <style>
            form label {
                float: left;
                width: 120px;
                text-align: left;
                position: relative;
                top: 2px;
                margin-right: 5px;
            }
        </style>
    </head>
    <body>
        <p align="right">
            <c:out value = "${sessionScope.firstName} ${sessionScope.lastName}" default="" />
            (<a href="login.jsp">Logout</a>)
        </p>

        <h1>Edit user</h1>

        <form method="POST" action="EditUser">
            <div>  
                <input type="hidden" name="id" value="${user.id}">
                <label>Login: </label><input type="text" value = "${user.login}" readonly name="login"> </p>
                <label>Password: </label><input type="password" name="password" required> <font color="red">*</font></p>
                <label>Password again: </label><input type="password" name="passwordagain" required> <font color="red">*</font></p>
                <label>E-mail: </label><input type="email" name="email" required> <font color="red">*</font></p>
                <label>First name: </label><input type="text" name="firstname" required> <font color="red">*</font></p>
                <label>Last name: </label><input type="text" name="lastname"required> <font color="red">*</font></p>
                <label>Birthday: </label><input type="text" name="birth" required> <font color="red">*</font> format: yyyy-MM-dd </p>
                <label>Role:</label><select name="role">
                    <option value="User">User</option>
                    <option value="Admin">Admin</option>
                </select> <font color="red">*</font></p>
                <input type="submit" value="Ok"/>
                <input  type="button" value="Cancel" onclick="javascript:history.back();" />
            </div>
        </form>
    </body>

    <p align="center">
        <span style="color: red">
            <% if ((request.getAttribute("error")) != null) {
                    out.println(request.getAttribute("error"));
                }
            %> 
        </span>
    </p>
</html>